package crontab

import (
	"wechat-push/config"
	"wechat-push/internal"
	"wechat-push/pkg/logger"

	"github.com/robfig/cron"
)

var Cron = cron.New()

func Schedule() (err error) {
	// 增加定时任务
	err = Cron.AddFunc(config.Cfg.Cron.Spec, internal.SendMorning)
	if err != nil {
		logger.Log.Error("crontab.AddFunc err :", err)
		return

	}
	Cron.Start()
	logger.Log.Info("crontab spec : ", config.Cfg.Cron.Spec)
	return
}
